package com.qcby.demo.spi.starter;

import com.qcby.demo.spi.starter.service.IHelloService;
import com.qcby.demo.spi.starter.service.impl.HelloServiceImpl;
import com.qcby.demo.spi.starter.service.properties.HelloMsgProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisOperations;

/**
 * @className: SelfAutoConfig
 * @description: 自动加载的配置类
 * @author: lxt
 * @create: 2021-05-20 21:19
 **/
@Configuration
// 条件注解：添加redis starter后自动生效
@ConditionalOnClass({RedisOperations.class})
@EnableConfigurationProperties({HelloMsgProperties.class})
public class SelfAutoConfiguration {

    @Bean
    @ConditionalOnMissingBean(IHelloService.class)
    public IHelloService helloService(){
        return new HelloServiceImpl();
    }

}
